<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>

<html class="app-ui">

<head>
    <!-- Meta -->
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>

    <!-- Document title -->
    <title>我的个人信息</title>

    <meta name="description" content="AppUI - Admin Dashboard Template & UI Framework"/>
    <meta name="author" content="rustheme"/>
    <meta name="robots" content="noindex, nofollow"/>

    <!-- Favicons -->
    <link rel="apple-touch-icon" href="${pageContext.request.contextPath}/assets/img/favicons/apple-touch-icon.png"/>
    <link rel="icon" href="${pageContext.request.contextPath}/assets/img/favicons/favicon.ico"/>

    <!-- Google fonts -->
    <link rel="stylesheet"
          href="http://fonts.googleapis.com/css?family=Roboto:300,400,400italic,500,900%7CRoboto+Slab:300,400%7CRoboto+Mono:400"/>

    <!-- AppUI CSS stylesheets -->
    <link rel="stylesheet" id="css-font-awesome" href="${pageContext.request.contextPath}/assets/css/font-awesome.css"/>
    <link rel="stylesheet" id="css-ionicons" href="${pageContext.request.contextPath}/assets/css/ionicons.css"/>
    <link rel="stylesheet" id="css-bootstrap" href="${pageContext.request.contextPath}/assets/css/bootstrap.css"/>
    <link rel="stylesheet" id="css-app" href="${pageContext.request.contextPath}/assets/css/app.css"/>
    <link rel="stylesheet" id="css-app-custom" href="${pageContext.request.contextPath}/assets/css/app-custom.css"/>
    <!-- End Stylesheets -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/js/layui/css/layui.css" media="all">
</head>

<body class="app-ui layout-has-drawer layout-has-fixed-header">
<div class="app-layout-canvas">
    <div class="app-layout-container">

        <!-- Drawer -->
        <aside class="app-layout-drawer">

            <!-- Drawer scroll area -->
            <div class="app-layout-drawer-scroll" style="margin-top: 50px;">
                <!-- Drawer logo -->
                <div id="logo" class="drawer-header"
                     style="text-align: center;margin: 0 auto;font-family: 华文楷体; padding-top: 20px;">
                    <span style="font-size: 34px;"><strong>我的账户</strong></span>
                </div>

                <!-- Drawer navigation -->
                <nav class="drawer-main">
                    <ul class="nav nav-drawer">
                        <li class="nav-item nav-drawer-header">
                            <hr color="#ccc">
                        </li>
                        <li class="nav-item">
                            <a href="${pageContext.request.contextPath}/jsp/MyAccount/MyMoneyRecord.jsp"><i class="ion-ios-speedometer-outline"></i>
                                <span>我的账户流水</span></a>
                        </li>
                        <li class="nav-item">
                            <a href="javascript:void(0)"><i class="ion-ios-monitor-outline"></i> <span  style="font-size: 20px;">我的信息</span></a>
                        </li>
                        <li class="nav-item">
                            <a href="${pageContext.request.contextPath}/jsp/MyAccount/myOrder.jsp"><i class="ion-ios-monitor-outline"></i> 我的订单</a>
                        </li>
                        <li class="nav-item">
                            <a href="${pageContext.request.contextPath}/jsp/MyAccount/myReceiveAddress.jsp"><i class="ion-ios-monitor-outline"></i> 我的收获地址</a>
                        </li>
                        <li class="nav-item">
                            <a href="${pageContext.request.contextPath}/jsp/MyAccount/myOpinion.jsp"><i class="ion-ios-monitor-outline"></i> 我的评价</a>
                        </li>
                    </ul>
                </nav>
                <!-- End drawer navigation -->
            </div>
            <!-- End drawer scroll area -->
        </aside>
        <!-- End drawer -->

        <!-- Header -->
        <header class="app-layout-header">
            <nav class="navbar navbar-default">
                <div class="container">
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                                data-target="#header-navbar-collapse"
                                aria-expanded="false">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <button class="pull-left hidden-lg hidden-md navbar-toggle" type="button" data-toggle="layout"
                                data-action="sidebar_toggle">
                            <span class="sr-only">Toggle drawer</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <a class="navbar-brand" href="${pageContext.request.contextPath}/jsp/home/frontend_home.jsp">
                            <img class="img-responsive"
                                 src="${pageContext.request.contextPath}/assets/img/logo/logo-frontend.png"
                                 title="强强组合商城" alt="AppUI"/>
                        </a>
                    </div>

                    <div class="collapse navbar-collapse" id="header-navbar-collapse">
                        <ul id="main-menu" class="nav navbar-nav navbar-left">
                            <li class="">
                                <a href="${pageContext.request.contextPath}/jsp/home/frontend_home.jsp">首页</a>
                            </li>
                            <li class="">
                                <a href="#" data-toggle="dropdown">关于我们</a>
                            </li>
                        </ul>
                        <!-- .navbar-left -->

                        <ul class="nav navbar-nav navbar-right navbar-toolbar hidden-sm hidden-xs">
                            <li class="active" id="business">
                                <a href="frontend_home.html">注册为商家</a>
                            </li>
                            <li class="active" id="deliver">
                                <a href="frontend_home.html">注册为配送员</a>
                            </li>
                            <li class="dropdown">
                                <a href="javascript:void(0)" data-toggle="dropdown"><i class="ion-ios-bell"></i> <span class="badge">3</span></a>
                                <ul class="dropdown-menu dropdown-menu-right">
                                    <li class="dropdown-header">消息</li>
                                    <li>
                                        <a tabindex="-1" href="javascript:void(0)"><span class="badge pull-right">3</span> 有无内鬼？ </a>
                                    </li>
                                    <li>
                                        <a tabindex="-1" href="javascript:void(0)"><span class="badge pull-right">1</span> 不过如此 </a>
                                    </li>
                                    <li class="divider"></li>
                                    <li class="dropdown-header">公告</li>
                                    <li>
                                        <a tabindex="-1" href="javascript:void(0)">登dua郎..</a>
                                    </li>
                                </ul>
                            </li>

                            <li class="dropdown dropdown-profile">
                                <a href="javascript:void(0)" data-toggle="dropdown">
                                    <span class="m-r-sm">${account.accName}<span class="caret"></span></span>
                                    <img class="img-avatar img-avatar-48" src="${pageContext.request.contextPath}/file/acc/${account.accImg == null?"000000011612245316757212.png":account.accImg}" alt="User profile pic" />
                                </a>
                                <ul class="dropdown-menu dropdown-menu-right">
                                    <li>
                                        <a href="${pageContext.request.contextPath}/jsp/MyAccount/MyMoneyRecord.jsp">个人账户</a>
                                    </li>
                                    <li>
                                        <a href="${pageContext.request.contextPath}/jsp/MyAccount/myBuyCart.jsp">我的购物车</a>
                                    </li>
                                    <li>
                                        <a href="#" id="logout">退出</a>
                                    </li>
                                </ul>
                            </li>
                        </ul>
                        <!-- .navbar-right -->
                    </div>
                </div>
                <!-- .container-fluid -->
            </nav>
            <!-- .navbar-default -->
        </header>
        <!-- End header -->

        <main class="app-layout-content">

            <!-- Page Content -->
            <div class="container-fluid p-y-md">
                <!-- Cards API, functionality initialized in App() -> uiCardsApi() -->
                <div class="row">

                    <div class="col-sm-12">
                        <div class="card">
                            <div class="card-header">
                                <h4>我的信息</h4>
                            </div>
                            <div class="card-block">
                                <form class="js-validation-bootstrap form-horizontal m-t-sm" id="submitForm" action="${pageContext.request.contextPath}/accountInfo/editAccountByAccount" method="post" enctype="multipart/form-data">
                                    <div class="form-group">
                                        <div class="col-sm-12">
                                            <div class="form-control-static">
                                                <label>当前头像 ：</label>
                                                <img src="${pageContext.request.contextPath}/assets/img/photos/photo3.jpg" id="accImg" style="width: 180px;height: 150px;" />
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-12">
                                            <div class="form-control-static" style="margin-left: 90px;">
                                                <input type="file" id="imgFile" />
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-9">
                                            <div class="form-control-static">
                                                <label>真实姓名：</label>
                                                <span id="turename">黄**</span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group has-success">
                                        <label class="col-xs-1">昵称：</label>
                                        <div class="col-sm-5">
                                            <input class="form-control" type="text" id="accName" name="example-text-input-success"
                                                   placeholder="起个好名字吧..." value="" />
                                        </div>
                                    </div>
                                    <div class="form-group has-info">
                                        <label class="col-sm-1">电话:</label>
                                        <div class="col-sm-5">
                                            <input class="form-control" type="text" id="accTelephone" name="val-number"
                                                   placeholder="联系电话..." />
                                        </div>
                                    </div>
                                    <div class="form-group  has-info">
                                        <label class="col-md-1">邮箱： </label>
                                        <div class="col-md-5">
                                            <input class="form-control" type="text" id="accEmail" name="val-email" placeholder="请输入邮箱...">
                                        </div>
                                    </div>
                                    <div class="form-group has-warning">
                                        <div class="col-xs-5">
                                            <label class="css-input css-radio css-radio-info m-r-sm">性别：
                                                <input type="radio" id="accSexMan" class="accSex" name="radio-group3" checked="" value="1"><span></span> 男
                                            </label>
                                            <label class="css-input css-radio css-radio-info">
                                                <input type="radio" class="accSex" id="accSeMen" name="radio-group3" checked="" value="2"><span></span> 女
                                            </label>
                                        </div>
                                    </div>
                                    <div class="form-group has-error">
                                        <label class="col-sm-1">生日：</label>
                                        <div class="col-xs-5">
                                            <div class="form-material">
                                                <input class="js-datepicker form-control" type="text" id="accBirthday" name="example-datepicker4"
                                                       data-date-format="yyyy-mm-dd" placeholder="yyyy-mm-dd" value="">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group m-b-0">
                                        <div class="col-md-8 col-md-offset-4">
                                            <button class="btn btn-app" type="submit">确认</button>
                                            <button class="btn btn-app" type="reset">重置</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <!-- .card-block -->
                        </div>
                    </div>
                    <!-- .col-sm-12 -->
                </div>
            </div>
            <!-- .row -->
        </main>

    </div>
    <!-- .app-layout-container -->
</div>

<!-- .app-layout-canvas -->

<!-- AppUI Core JS: jQuery, Bootstrap, slimScroll, scrollLock and App.js -->
<!-- AppUI Core JS: jQuery, Bootstrap, slimScroll, scrollLock and App.js -->
<script src="${pageContext.request.contextPath}/assets/js/core/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/core/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/core/jquery.slimscroll.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/core/jquery.scrollLock.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/core/jquery.placeholder.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/app-custom.js"></script>

<!-- Page JS Plugins -->
<script src="${pageContext.request.contextPath}/assets/js/plugins/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/plugins/bootstrap-colorpicker/bootstrap-colorpicker.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/plugins/select2/select2.full.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/plugins/masked-inputs/jquery.maskedinput.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/plugins/dropzonejs/dropzone.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/plugins/jquery-tags-input/jquery.tagsinput.min.js"></script>
<div class="app-ui-mask-modal"></div>

<script src="${pageContext.request.contextPath}/js/My97DatePicker/WdatePicker.js"></script>
<script src="${pageContext.request.contextPath}/js/layui/layui.js"></script>

<script type="text/javascript">
    $(function () {
        //商家id
        var accId = ${account.accId};
        getMyInfo();
        function getMyInfo() {
            var param = {
                accId:accId
            }
            var url = "${pageContext.request.contextPath}/accountInfo/selectAccountByAccId";

            /*  回显账户信息  */
            $.get(url,param,function (data){
                $("#accImg").attr("src","${pageContext.request.contextPath}/file/acc/"+data.account.accImg);
                $("#turename").html(data.account.accTruename);
                $("#accName").val(data.account.accName);
                $("#accTelephone").val(data.account.accTelephone);
                $("#accEmail").val(data.account.accEmail);
                if (data.account.accSex == 1){
                    $("#accSexMan").prop("checked",true);
                }else{
                    $("#accSexMen").prop("checked",true);
                }
                $("#accBirthday").val(data.account.accBirthday);
            });
        }


        $("#submitForm").submit(function (event){
            event.preventDefault();
            var sex = $(".accSex");
            var accSex;
            if ($(sex[0]).prop("checked") == true){
                accSex = $(sex[0]).val();
            }else {
                accSex = $(sex[1]).val();
            }
            var formData = new FormData();
            formData.append("accImg", $("#imgFile")[0].files[0]);
            formData.append("accTruename",$("#turename").html());
            formData.append("accName",$("#accName").val());
            formData.append("accId",accId);
            formData.append("accTelephone",$("#accTelephone").val());
            formData.append("accEmail",$("#accEmail").val());
            formData.append("accSex",accSex);
            formData.append("accBirthday",$("#accBirthday").val());
            var url = $(this).attr("action");
            $.ajax({
                type:'POST',
                url:url,
                data:formData,
                contentType:false,
                processData:false,//这个很有必要，不然不行
                dataType:"json",
                mimeType:"multipart/form-data",
                success:function(data){
                    if(1001 == data.code){
                        alert("保存成功!");
                        getMyInfo();
                    }else{
                        alert("保存失败!"+data.message);
                    }
                }
            });
        });


        /*动态显示首页头部*/
        var role = ${account.role};
        if(role == 2){
            $("#business").html("<a href='../business/UnFinishOrder.jsp'>商家后台</a>");
            $("#deliver").html("");
        }
        if(role == 3){
            $("#business").html("");
            $("#deliver").html("<a href='#'>配送员后台</a>");
        }
        /*退出登录*/
        $("#logout").click(function (event){
            event.preventDefault();
            var url = "/login/logoutShop";
            $.post(url,function (){
                window.location.href = "../../login.jsp";
            })
        })
        //模态框居中问题 start
        function centerModals() {
            $('.modal').each(function (i) {
                var $clone = $(this).clone().css('display', 'block').appendTo('body');
                var top = Math.round(($clone.height() - $clone.find('.modal-content').height()) / 2);
                top = top > 50 ? top : 0;
                $clone.remove();
                $(this).find('.modal-content').css("margin-top", top - 50);
            });
        }

        // 在模态框出现的时候调用垂直居中方法
        $('.modal').on('show.bs.modal', centerModals);
        // 在窗口大小改变的时候调用垂直居中方法
        $(window).on('resize', centerModals);
        //模态框居中问题end

    });
</script>

</body>

</html>
